package com.wiz.weixin.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wiz.weixin.TO.PrPriceTO;
import com.wiz.weixin.mapper.PrPriceMapper;
import com.wiz.weixin.service.PrPriceService;
import com.wiz.weixin.util.PageView;

@Service("prPriceService")
public class PrPriceServiceImpl implements PrPriceService {
	@Resource
	private PrPriceMapper prPriceMapper;

	@Override
	public PageView listPrPrice(PageView pageView,List<String> list) {
		Map<String, List<PrPriceTO>> map = new HashMap<String, List<PrPriceTO>>();
		List<String>stationIds = new ArrayList<String>();
		List<PrPriceTO> prPrice = null;
		String stationId = null;
		
		if(list == null || list.size()<=0){
			return pageView;
		}
		
		Map<Object, Object> parammap = new HashMap<Object, Object>();
		parammap.put("paging", pageView);
		parammap.put("list", list);
		List<PrPriceTO> result = prPriceMapper.query(parammap);
		for(int i = 0; i<result.size(); i++){
			stationIds.add(result.get(i).getStationId());
		}
		
		result = prPriceMapper.queryByStationId(stationIds);
		for (PrPriceTO prPriceTO : result) {
			stationId = prPriceTO.getStationId();
			if(map.containsKey(stationId)){
				prPrice = map.get(stationId);
			}else{
				prPrice = new ArrayList<PrPriceTO>();
			}
			prPrice.add(prPriceTO);
			map.put(stationId, prPrice);
		}
		pageView.setMap(map);
		return pageView;
	}

}
